<%@ page language="java" import="java.util.*" import="SiTuQingYou.vo.*"  contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
	#page{ width:100%;height:280vh;}
	#title{text-align:center;width:100%;height:100px;line-height:100px;color:darkcyan;}
	#scenes{ border:1px solid gray; height:450px; width:1000px;margin:0px auto;}
	#scenes img{width:550px;height:420px;}
	#content{float:left;margin:10px 10px;}
	#info{float:left;width:400px;height:420px;margin:10px 10px;color:purple;}
	#detail{width:400px;height:140px;}
    #strategy
    {
    
   
     
    }
    #divs
 {
 margin-left:210px;
 width:930px;
 height:200px;
 
 margin-top:20px;
 }
#divleft
{
margin-left:10px;
float:left;
width:300px;
height:200px;
 
}
#divright
{
background-color:#ddd;
margin-left:10px;
float:left;
width:600px;
height:200px;
 
}
#titlex
{
text-align:center;
 
width:300px;
height:30px;
margin-left:100px;
}
#contentx
{
height:65px;
font-size:15px;
margin-top:10px;
 
width:500px;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:3;
overflow:hidden;
text-overflow:ellipsis;/* 支持 IE */
 
}
#contentx>a
{
text-decoration: none;
}
#author a
{
text-decoration: none;
}
#title>a
{
text-decoration: none;
}

#author
{
margin-top:50px;
width:600px;
height:30px;
 
}
#divleft img
{
width:100%;
height:100%;
}
#more
{
margin-top:20px;
width:1000px;
text-align: right;
}
#author span
{
float:right;
margin-right:10px;
}
#imgg
{
width:300px;
height:200px;
}
#titles
{
 
margin-top:20px;
width:200px;
margin-left:210px;
}

    


</style>

 <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
<!-- 点赞 -->
<script type="text/javascript">
$(document).ready(load);
function load()
{
   $(document).ready(function(){
	   $("span[id=lik]").click(function(){
		  var id=$(this).attr("cid");
		  var t=$(this);
		  var count=$(this).prev().html();
		  count=parseInt(count);
		  $.ajax(
				  {
					  url:"<%=path%>/MyCollectionServlet",
					  type:"post",
					  data:"method=checkStrategyLikeServlet&id="+id,
					  success:function(mes){
						  if(mes==2)
							{
							 location.href = "/SiTuQingYou/anotherLogReg/login.jsp";
							}
							if(mes==1)
						    	{
								count--;
								t.prev().html(count);
								t.children().css("color","black");
						    	 
						    	}
						    if(mes==0)
					    	{
						    count++;
						    t.prev().html(count);
						    t.children().css("color","red");
					    	}	
							}
				  });
		   
		   
	   });
	   
   });
}


</script>
<!-- 得出该攻略总赞数 -->
<script type="text/javascript">
$(document).ready(function(){
	 
	 var totals=$("span[id=total]");
	 var cids="";
		totals.each(function()
		{
		var cid=$(this).attr("cid");
		cids=cids+"&"+"cid="+cid;	
		});
	
	 $.ajax(
			  {
				  url:"<%=path%>/MyCollectionServlet",
				  type:"post",
				  data:"method=getManyToatalLike"+cids,
				  success:function(mes){
					   var str=mes;
					   str=str.substring(1);
					   var totalss=new Array();
					   totalss=str.split(",");
					   var i=0;
					   totals.each(function()
								{
								 $(this).html(totalss[i]);
								 i++;	
								});
					  
					  
						}
			  });
	
});
</script>
 <script type="text/javascript">
$(document).ready(load);
function load()
{
   $(document).ready(function(){
	   $("span[id=col]").click(function(){
		  var id=$(this).attr("cid");
		  $.ajax(
				  {
					  url:"<%=path%>/MyCollectionServlet",
					  type:"post",
					  data:"method=checkStrategyCollectionServlet&id="+id,
					  success:function(mes){
						if(mes==2)
							{
							 location.href = "/SiTuQingYou/anotherLogReg/login.jsp";
							}
							if(mes==1)
						    	{
								$("#col").children().css("color","black");
						    	alert("取消收藏")
						    	}
						    if(mes==0)
					    	{
						    $("#col").children().css("color","red");
					    	alert("收藏成功")
					    	}	
							}
				  });
		   
	   });
	   
   });
}
</script> 
  
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<div id="page">
	<div id="title"><font size="10px" face="隶书">景点详情</font></div>
	<div id="scenes">
	<jsp:include page="/ScenehomeServlet"><jsp:param value="sceneinfo" name="method"/></jsp:include>
	<jsp:include page="/ScenehomeServlet"><jsp:param value="getpicture" name="method"/></jsp:include>
	<%Scene scene = (Scene)request.getAttribute("scene");
	ArrayList<String> pics = (ArrayList<String>) request.getAttribute("pics");
		String str = "";
		if(scene.isHot()==true){str="热门";}
	%>
	<div>
		<div id="content"><img src="<%=path%>/images/<%=pics.get(0)%>"></div>
			<div id="info">
				<div id="detail">景点名称：<%=scene.getScenename()%></div>	
				<div id="detail">景点简介：<%=scene.getIntro() %></div>
				<div id="detail">景点分类：<%=scene.getTheme().getClassname()+"<br/>"+str%></div>
			</div>
		 
	</div>
	</div>
	<div id="strategy">
	<div id="titles"><h2>相关攻略</h2></div>
	<jsp:include page="/StrategyServlet"><jsp:param value="getAllStrategyBySceneId" name="method"/><jsp:param value="<%=scene.getId() %>" name="id"/></jsp:include>
	<%ArrayList<Strategy>strategys=(ArrayList<Strategy>)request.getAttribute("strategys");%>
	
	<%
			for(int i=0;i<strategys.size();i++)
			{
			%><div id="divs">
					<div id="divleft"><a href="<%=path%>/index/strategyinformation.jsp?id=<%=strategys.get(i).getId()%>"><img src="<%=path%>/imagess/<%=strategys.get(i).getPhoto()%>"/></a></div>
					<div id="divright">
					<div id="titlex"><a href="<%=path%>/index/strategyinformation.jsp?id=<%=strategys.get(i).getId()%>"><h4><%=strategys.get(i).getTitle()%></h4>  </a></div>
					<div id="contentx"><a href="<%=path%>/index/strategyinformation.jsp?id=<%=strategys.get(i).getId()%>"><%=strategys.get(i).getContent() %></a></div>
					<div id="author"><span>by <%=strategys.get(i).getUser().getUsernickname()%></span> 
					<span id="col" cid="<%=strategys.get(i).getId()%>"><a href="script:void(0)">收藏</a></span>
					<span id="total" cid="<%=strategys.get(i).getId()%>">0</span>
					<span id="lik" cid="<%=strategys.get(i).getId()%>"><a href="script:void(0)">点赞</a></span>
					
					</div>
					</div>
					
					</div>
					 <%  
			}
	%>
	</div>	
</div>	
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>